(function () {
    //严谨模式 检查所有错误
    'use strict';
    var window_flag_1 = 'object1'; // 修改为需要hook的对象
    var window_flag_2 = 'object2'; // hook对象的对象

    var key_value_map = {};
    var window_value = window[window_flag_1];

    Object.defineProperty(window, window_flag_1, {
        get: function () {
            debugger;
            console.log('Getting', window, window_flag_1, '=', window_value)
            return window_value;
        },
        set: function (val) {
            debugger;
            console.log('Setting', window, window_flag_1, '=', val);
            window_value = val;
            key_value_map[window[window_flag_1]] = window_flag_1;
            set_obj_attr(window[window_flag_1], window_flag_2);
        },
    });

    function set_obj_attr(obj, attr) {
        var obj_arrt_value = obj[attr];
        Object.defineProperty(obj, attr, {
            get: function () {
                console.log('Getting', key_value_map[obj], attr, '=', obj_arrt_value);
                debugger;
                return obj_arrt_value
            },
            set: function (val) {
                console.log('Setting', key_value_map[obj], attr, '=', val);
                debugger;
                obj_arrt_value = val;
            },
        });
    };
})();